<?php

// For autoresponse
define('XOAD_AUTOHANDLE', TRUE);
require_once('XOAD/xoad.php');

class FRM_XOAD
{
	static protected $_objects = '';

	static public function register($name,$object)
	{
		// :TODO: validate object name and throw an exception if not good
		self::$_objects .= "var $name = ".XOAD_Client::register($object,array('class' => get_class($object))).';'.PHP_EOL;
	}

	static public function getClientCode()
	{
		// :KLUDGE:
		// Needs to wait for 1.3 before rewriting this part
		$base_url = FRM_Config::get('APPLICATION','URL');
		// :TODO:
		// Add this as part of the config
		$base_url.= '/FRM/staticContent/xoad';

		$ccode = FRM_XOAD_Utilities::header($base_url).PHP_EOL;
		$ccode.= '<script type="text/javascript">'.PHP_EOL;
		$ccode.= self::$_objects;
		$ccode.= '</script>'.PHP_EOL;

		return $ccode;
	}
}